package com.xuhf.producerType;

import com.alibaba.fastjson.JSONObject;
import com.xuhf.config.Config;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class SyncProducer {

    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer(Config.PRODUCER_GROUP);
        producer.setNamesrvAddr(Config.NAMESRV_ADDR);
        producer.start();
        for (int i = 0; i < 100; i++) {
            Message message = new Message("04-producer-type", "tagc", ("heleeo " + i).getBytes());
            SendResult sendResult = producer.send(message);
            System.out.println(JSONObject.toJSONString(sendResult));
        }
        producer.shutdown();
    }
}
